package com.ity.teamanagement.controller;

import com.ity.teamanagement.entity.inputParam.UserLogin;
import com.ity.teamanagement.result.Result;
import com.ity.teamanagement.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;

/**
 * @author coderFu
 * @create 2021/5/23
 */
@RestController
@Api(tags = "后台登录模块")
@RequestMapping("/auth")
public class AuthController {

    @Autowired
    private UserService userService;


    @PostMapping(value = "/login", name = "用户登录")
    @ApiOperation("用户登录")
    public Result getAuth(@RequestBody UserLogin userLogin, HttpServletResponse response) {
        return Result.success(userService.queryUserByUserNameAndPwd(userLogin, response));
    }

    @DeleteMapping(value = "/logout", name = "退出登录")
    @ApiOperation("退出登录")
    public Result logout(){
        userService.logout();
        return Result.success();
    }
}
